package ar.drools.apuestas.controllers;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ar.drools.apuestas.main.Sistema;
import ar.drools.apuestas.modelo.Piloto;

public class HomeController extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public HomeController() {
		super();
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		RequestDispatcher rd = getServletContext().getRequestDispatcher("/index.jsp");
		rd.forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		List<Piloto> pilotos = Sistema.obtenerPrediccion();

		request.setAttribute("PILOTOS", pilotos);
		RequestDispatcher rd = getServletContext().getRequestDispatcher("/resultadosApuestas.jsp");
		rd.forward(request, response);
	}

}
